<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center share_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub share_fd0_0'>
					<view class='flex flex-wrap align-center share_fd0_0_c0' @tap="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  share_fd0_0_c0_c0'>&#xe794;</text>
					</view>
					<view class='flex flex-wrap align-center share_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-center benben-flex-layout share_flex_1">
				<image class='share_fd1_0' mode="aspectFit" :src='shareData.avatar'></image>
				<text class='share_fd1_1'>{{shareData.nickname}}</text>
				<image class='share_fd1_2' mode="aspectFit" :src='shareData.url'
					@tap.stop="singleImagePreview(shareData.url)"></image>
				<button class='share_fd1_3' @tap.stop="getSharingFunc()">立即分享</button>
				<button class='share_fd1_4' @tap="saveHttpImgFunc()">保存图片到相册</button>
			</view>

			<!---flex布局flex布局结束-->
			<benben-popup v-model="popupShow1692774862897" :mask="true" :mask-close-able="true" mode='bottom'>
				<!---分享弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout share_flex_2">
					<view class='flex flex-wrap align-center justify-between share_fd2_0'>
						<view class='flex flex-wrap align-center share_fd2_0_c0'>
						</view>
						<text class='share_fd2_0_c1'>分享到</text>
						<image class='share_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"157.png"'
							@tap.stop="popupShow1692774862897=false"></image>
					</view>
					<view class='flex flex-wrap align-center justify-between share_fd2_1'>
						<view class='flex flex-direction flex-wrap align-center' @tap.stop="shareWxFunc()">
							<image class='share_fd2_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"160.png"'></image>
							<text class='share_fd2_1_c0_c1'>微信好友</text>
						</view>
						<view class='flex flex-direction flex-wrap align-center' @tap.stop="shareCircleFunc()">
							<image class='share_fd2_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"161.png"'></image>
							<text class='share_fd2_1_c0_c1'>朋友圈</text>
						</view>
					</view>
				</view>

				<!---分享弹窗flex布局结束-->

			</benben-popup>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1692774862897": false,
				"shareData": {
					"invite_code": "",
					"user_id": "",
					"url": "",
					"avatar": "",
					"real_name": "",
					"filepath": "",
					"content": "",
					"nickname": ""
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			this.getShareFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取分享信息
			async getShareFunc() {
				//请求方法
				//数据验证

				let datashareData = await this.$api.get(global.apiUrls.post63a6ca64aa13a, {

				});

				if (datashareData.data.code != 1) {
					this.$message.info(datashareData.data.msg);
					return
				}
				let infoshareData = datashareData.data;
				this.shareData = infoshareData.data

			},
			//保存分享二维码至手机相册
			saveHttpImgFunc() {
				if (!this.setCheckPermission(6)) {
					return
				}
				uni.showLoading({
					title: '二维码下载中'
				});
				uni.downloadFile({
					url: this.shareData.url,
					success: (res) => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: () => {
									uni.hideLoading();
									this.$message.info("图片已保存");
								},
								fail: () => {
									uni.hideLoading();
									this.$message.info("保存失败");
								},
								complete: () => {
									uni.hideLoading();
								}
							});
						}
					},
					fail: error => {
						this.$message.info("保存失败");
					}
				});
			},
			//app或小程序分享
			getSharingFunc() {
				if (this.appSystemIdentification != 'Wechat') {
					this.popupShow1692774862897 = true
				} else if (this.appSystemIdentification == 'Wechat') {
					uni.downloadFile({
						url: this.shareData.url,
						success: (res) => {
							if (res.statusCode === 200) {
								wx.showShareImageMenu({
									path: res.tempFilePath,
									success: (res) => {
										console.log("分享成功：", res);
									},
									fail: (err) => {
										console.log("分享取消：", err);
									},

								})
							}
						},
						fail: error => {
							this.$message.info("保存失败");
						}
					});
				}
			},
			//分享微信聊天
			async shareWxFunc() {
				await this.syncUniApi('share', {
					'provider': 'weixin',
					'scene': 'WXSceneSession',
					'type': '0',
					'title': this.shareData.title,
					'href': this.shareData.filepath,
					'summary': this.shareData.content,
					'imageUrl': this.shareData.url
				})
			},
			//分享朋友圈
			async shareCircleFunc() {
				await this.syncUniApi('share', {
					'provider': 'weixin',
					'scene': 'WXSceneTimeline',
					'type': '0',
					'title': this.shareData.title,
					'href': this.shareData.filepath,
					'summary': this.shareData.content,
					'imageUrl': this.shareData.url
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(image-path('155.png')) no-repeat;
		background-size: cover;
	}

	.share_flex_0 {
		background: url(image-path('155.png')) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.share_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.share_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.share_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.share_flex_1 {
		background: rgba(255, 255, 255, 1);
		margin: 250rpx 75rpx 0rpx 75rpx;
		background-size: 100% auto;
		border-radius: 16rpx;
		box-shadow: 0rpx 3rpx 24rpx rgba(77, 135, 247, 0.1);
		padding: 56rpx 0rpx 0rpx 0rpx;
	}

	.share_fd1_4 {
		border: 1px solid #4186FF;
		background: #FFFFFF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		width: 480rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		color: rgba(65, 134, 255, 1);
		height: 88rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.share_fd1_3 {
		background: #3090FF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		width: 480rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		color: #fff;
		height: 88rpx;
		margin: 108rpx 0rpx 32rpx 0rpx;
	}

	.share_fd1_2 {
		width: 320rpx;
		height: 320rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.share_fd1_1 {
		color: #333333;
		font-size: 30rpx;
		font-weight: 500;
		line-height: 40rpx;
		max-width: 500rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-align: center;
		margin: 16rpx 0rpx 32rpx 0rpx;
	}

	.share_fd1_0 {
		width: 80rpx;
		height: 80rpx;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
	}

	.share_flex_2 {
		background: #fff;
		background-size: 100% auto !important;
		border-radius: 32rpx 32rpx 0rpx 0rpx;
	}

	.share_fd2_1_c0_c1 {
		line-height: 33rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333333;
		margin: 16rpx 0rpx 0rpx 0rpx;
	}

	.share_fd2_1_c0_c0 {
		width: 80rpx;
		height: 80rpx;
	}

	.share_fd2_1 {
		margin: 40rpx 212rpx 66rpx 212rpx;
	}

	.share_fd2_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.share_fd2_0_c0 {
		width: 30rpx;
		height: 30rpx;
	}

	.share_fd2_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 32rpx 32rpx 32rpx;
	}
</style>